package org.qiyu.live.id.generate.provider;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.qiyu.live.id.generate.provider.service.IdGenerateService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

import java.util.HashSet;

/**
 * @author: c
 * @date: 2024/3/1 13:27
 * @description:
 */

@SpringBootApplication
@Slf4j
public class IdGenerateApplication implements CommandLineRunner {

    @Resource
    private IdGenerateService idGenerateService;


    public static void main(String[] args) {
        SpringApplication springApplication = new SpringApplication(IdGenerateApplication.class);
        springApplication.setWebApplicationType(WebApplicationType.NONE); // 不需要使用tomcat,是纯粹的netty应用进程
        springApplication.run(args);
    }

    @Override
    public void run(String... args) throws Exception {


        HashSet<Object> objects = new HashSet<>();
        for (int i = 0; i < 1300; i++) {

            Long seqId = idGenerateService.getUnSeqId(1);
            objects.add(seqId);

        }

        System.out.println(objects.size());

        HashSet<Object> objects2 = new HashSet<>();
        for (int i = 0; i < 1300; i++) {

            Long seqId = idGenerateService.getSeqId(1);
            objects2.add(seqId);

        }

        System.out.println(objects2.size());
    }
}
